<!--
 * @Author: Nxf
 * @Date: 2024-06-13 15:50:30
 * @LastEditors: Nxf
 * @LastEditTime: 2024-06-13 16:01:00
 * @Descripttion: 
-->


<template>

    <div class="goodsTblDiv">

        <a-table :columns="columns" :data-source="orderLine" class="goodsTable" @resizeColumn="handleResizeColumn"
            :pagination="false" bordered>
            <template #title>
                <div class="titleDiv">{{ partner.display_name }}进场货物清单</div>
                <div class="titleInfoDiv">
                    <div class="infoName">
                        供货人名称:
                        <span>XXXXXXXXXXXXXXXX供应链有限责任公司</span>
                    </div>
                    <div class="infoTel">
                        联系电话:
                        <span>13222893045</span>
                    </div>
                    <div class="infoDate">
                        时间:
                        <span>2024年06月12日</span>
                    </div>
                </div>
            </template>
            <template #footer>
                <div class="footerDiv">
                    <div>
                        制表人:
                        <span>张三</span>
                    </div>
                    <div>
                        审核员:
                        <span>张三</span>
                    </div>
                    <div>
                        配送司机:
                        <span>张三</span>
                    </div>
                    <div>
                        证明人:
                        <span>张三</span>
                    </div>
                    <div>
                        验货人:
                        <span>张三</span>
                    </div>
                    <div>
                        经手人:
                        <span>张三</span>
                    </div>
                </div>
            </template>
        </a-table>
    </div>

</template>

<script setup>
import { computed, ref } from 'vue'


const props = defineProps({
    goodsInfoArr: {
        default: []
    },
    saleOrder: {
        default: {}
    }
})
const columns = ref([
    {
        key: 'index',
        title: '序号',
        dataIndex: 'index',
        width: 40,
        minWidth: 30,
        align: 'center',
        customRender: ({ text, record, index }) => {
            // console.log('---record, index---', text, record, index);
            // return `${index + 1}`
            return `${index + 1}`;
        }, // 关键句
    },
    {
        key: 'goodsCode',
        title: '编码',
        dataIndex: 'goodsCode',
        className: 'column-money',
        width: 90,
        // align: 'center',
        customCell: () => {
            return {
                style: {
                    //可以定义样式
                    // color: 'red',
                    textAlign: 'left'
                },
            };
        },
    },
    {
        key: 'goodsName',
        title: '品名',
        dataIndex: 'goodsName',
        width: 200,
        minWidth: 180,
        maxWidth: 250,
        resizable: true,
        // align: 'center'
        customCell: () => {
            return {
                style: {
                    //可以定义样式
                    // color: 'red',
                    textAlign: 'left'
                },
            };
        },
        // ellipsis: true,
    },
    {
        key: 'goodsNorms',
        title: '规格',
        dataIndex: 'goodsNorms',
        width: 100,
        align: 'center'
    },
    {
        key: 'goodsNumber',
        title: '数量',
        dataIndex: 'goodsNumber',
        width: 40,
        align: 'center'
    },
    {
        key: 'unitPrice',
        title: '单价/元',
        dataIndex: 'unitPrice',
        width: 60,
        align: 'center'
    },
    {
        key: 'totalPrice',
        title: '金额',
        dataIndex: 'totalPrice',
        width: 80,
        // align: 'center',
        customCell: () => {
            return {
                style: {
                    //可以定义样式
                    // color: 'red',
                    textAlign: 'right'
                },
            };
        },
    },
    {
        key: 'piecesNum',
        title: '备注',
        dataIndex: 'piecesNum',
        width: 50,
        align: 'center'
    },
]);
const partner = computed(() => {
    console.log('--saleOrder---', props.saleOrder);
    const dest_station_id = props.saleOrder.dest_station_id;
    const partner_id = props.saleOrder.partner_id;
    if (dest_station_id.id) {
        return dest_station_id
    } else {
        return partner_id
    }
})
const orderLine = computed(() => {
    const ss = (props.saleOrder.order_line || []).map(sol => {
        return {
            goodsId: sol.product_id.id, //货物ID
            barCode: sol.product_id.barcode, //条码
            goodsName: sol.product_id.name, //货物名称
            // goodsNorms: sol.product_uom.display_name, //货物规格
            goodsUnit: sol.product_uom.display_name || '', //货物单位
            goodsQuantity: sol.product_uom_qty || '', //采购数量
            buyingPrice: sol.price_unit || '', //供货价
            // piecesNum: '', //件数
            totalPrice: sol.price_total || '' //总价
        }
    })
    return ss;
})
//
function handleResizeColumn(w, col) {
    console.log('---w,col---', w, col);
    col.width = w;
}
</script>
<style lang="less" type="text/less" scoped>
.goodsTblDiv {
    background: gray;
    width: 100%;
    height: 100%;
    padding: 50px;

    .goodsTable {
        // background: red;
        min-width: 900px;
        max-width: 1000px;

        :deep(.ant-table-title) {
            padding: 0px;

            .titleDiv {
                // background: red;
                height: 50px;
                line-height: 50px;
                font-size: 30px;
                font-weight: bolder;
                text-align: center;
            }

            .titleInfoDiv {
                // background: tan;
                display: flex;
                height: 25px;
                line-height: 25px;

                span {
                    color: gray;
                }

                .infoName {
                    flex: 0 1 60%;
                    // background: yellow;
                    text-align: left;
                    padding-left: 10px;
                }

                .infoTel {
                    flex: 0 1 22%;
                    text-align: left;

                }

                .infoDate {
                    flex: 0 1 18%;
                    // background: pink;
                    text-align: left;

                }
            }
        }

        .footerDiv {
            display: flex;
            justify-content: space-between;
            padding-left: 5px;

            div {
                flex: 1;
                height: 20px;
                line-height: 20px;
                text-align: left;
                font-size: 12px;

                span {
                    color: gray;
                }
            }
        }

        :deep(.ant-table-thead > tr > th) {
            text-align: center;
        }

        :deep(.ant-table-footer) {
            margin: 0px;
            padding: 0px;
        }

        :deep(.ant-table-cell) {
            padding: 0px 3px;
            margin: 0px;
        }
    }
}
</style>
